<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class User_model extends CI_Model {

    public $tablename = 'hpg_user';
    
    
    public function insert($data){
        if( !$data ){
            return false;
        }
        $res = $this->db->insert($this->tablename, $data);
        return $this->db->insert_id();
    }
    
    public function search_uname($uname, $corp=0){
        $query = $this->db->from($this->tablename)->select('id,user_name,photo');
        if($uname){
            $query->like('user_name', $uname);
        }
        $query->where('corp_id', $corp);
        
        $list = $query->get_array();
        return $list;
    }
    
    public function getUserByUids($uids){
        $list = $this->db->from($this->tablename)->select('id,user_name,photo')->where_in('id', $uids)->get_array();
        return $list;
    }
    
    public function getUserByUnionid($unionid){
        $list = $this->db->from($this->tablename)->select('id,user_name,photo,corp_id,group_id')->where('unionid', $unionid)->fetchOne();
        return $list;
    }
}
?>